﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class AllUpgrateRecords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindUpgradeForms();
            }
        }

        private void BindUpgradeForms()
        {
            UpgradeService service = new UpgradeService();
            upgrateGridView.DataSource = service.GetUpgrateFoemByKeywords(keyWordTextBox.Text);
            upgrateGridView.DataBind();
        }

        protected void upgrateGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < upgrateGridView.PageCount)
            {
                upgrateGridView.PageIndex = e.NewPageIndex;
            }
            
            BindUpgradeForms();
        }

        protected void searchLinkButton_Click(object sender, EventArgs e)
        {
            BindUpgradeForms();
        }

        protected void resetLinkButton_Click(object sender, EventArgs e)
        {
            keyWordTextBox.Text = "";
            BindUpgradeForms(); 
        }

        protected void viewLinkButton_Click(object sender, EventArgs e)
        {
            string formID = ((LinkButton)sender).CommandArgument;
            Response.Redirect(string.Format("UpgradeRecordDetail.aspx?{0}={1}", Constants.QUERYSTR_UPGRADE_ID, formID));
        }
    }
}
